home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
gport.exe
/
GPORT.DOC
< prev
next >
Wrap
Text File
|
1993-04-09
|
27KB
|
1,164 lines
Gport
C Language Game Port Library
Version 1.01
1 September 91
Copyright (c) 1991 Bri Productions
1
Table of Contents
Introduction
General Description.....................3
Disclaimer..............................3
Registration............................3
Contacting the Author...................3
A typedef...............................3
General Functions
Description.............................4
GamOpen.................................5
GamClose................................6
GamAxis.................................6
GamAxes.................................7
GamButton...............................8
Calibration Functions
Description............................10
GamRawAxis.............................11
GamCalAxis.............................12
GamCenter..............................13
Appendix A - Things to Look Out For............15
Appendix B - Joystick Calibration/Centering....16
Appendix C - Registration Form.................18
2
General Description.
Gport is a C language, high speed, high resolution game port
library for IBM and compatible computers. Gport is compatible
with most if not all DOS based C compilers.
Some of Gport's features are:
∙ Timer driven button monitor.
∙ Optional joystick calibration.
∙ Choice of REAL or MEAN centering modes.
∙ Yields higher resolution on faster computers.
∙ Constant axis scaling to approximately ±1000.
∙ Written in assembly language for optimum speed and efficiency.
DISCLAIMER.
Gport is provided AS IS. Bri Productions specifically disclaims
any and all warranties, expressed or implied, including fitness
for a particular purpose. Use this product at your own risk.
Registration.
Gport is a user supported software product. Distribution of
this product, unaltered and without charge, is encouraged. If
you find this product useful, you are encouraged to register
your copy. This allows Bri Productions to continue to provide
and support low cost, high quality shareware.
The registration fee is $25.00 US dollars and includes libraries
for small, medium, compact and large memory models and complete
source code. A registration form is provided in Appendix C.
Contacting the author.
Bri Productions may be contacted by any of the following means:
U.S. mail - Bri Productions
P.O.Box 7121
Fremont, CA 94537-7121
Phone - (510) 794-0616
CompuServe - 76635,2246
CompuServe is a trademark of CompuServe Inc.
A typedef.
You will see the data type 'byte' throughout the Gport library.
This is a typedef defined in gport.h. Byte is an unsigned
character used for byte size values.
3
General functions
There are two functions that are required before other game
port functions can be called. They are GamOpen() and GamClose().
GamOpen() initializes the game port and installs an interrupt
handler for monitoring the buttons. GamClose() releases the
interrupt handler. Failing to call GamClose() prior to the
program's termination will most certainly cause an operating
system crash.
GamAxis() and GamAxes() fetches the position(s) of one or
more joystick axes. A full up or right joystick returns a value
of approximately +1000 and full down or left returns a value of
approximately -1000. GamButton() fetches the status of the game
port's buttons. Information on a button pressed since the last
call to GamButton() as well as a presently pressed is available.
4
----------------------------------------------------------------
GamOpen
----------------------------------------------------------------
Function
Initializes the game port and installs the interrupt
handler.
Syntax
#include "gport.h"
int GamOpen(void);
Remarks
GamOpen initializes the game port. If an axis is found to
be valid, it's corresponding bit is set in the returned
status word. After a call to GamOpen, a subsequent call
to GamClose is required. Failure to do so will most
definitely cause the operating system to crash.
Return Value
GamOpen returns a valid axis status word. The bits/values
are defined as follows:
JAX_VAL (0x1) - Joystick A, x axis valid
JAY_VAL (0x2) - Joystick A, y axis valid
JA_VAL (0x3) - Joystick A, both axes valid
JBX_VAL (0x4) - Joystick B, x axis valid
JBY_VAL (0x8) - Joystick B, y axis valid
JB_VAL (0xC) - Joystick B, both axes valid
See also
GamClose
Example
Attempt to open the game port and check Joystick A.
{
int valid_axes;
valid_axes = GamOpen();
if((valid_axis & JA_VAL) == JA_VAL)
{
...Joystick A OK
}
}
5
----------------------------------------------------------------
GamClose
----------------------------------------------------------------
Function
Releases the interrupt handler.
Syntax
#include "gport.h"
void GamClose(void);
Remarks
After a call to GamOpen, a subsequent call to GamClose
is required. Failure to do so will most definitely cause
the operating system to crash.
See also
GamOpen
Example
Close the game port prior to terminating.
{
...closing code
GamClose();
exit(0)
}
----------------------------------------------------------------
GamAxis
----------------------------------------------------------------
Function
Gets the coordinate of a joystick axis.
Syntax
#include "gport.h"
signed GamAxis(byte axis);
6
Parameters
axis - Constant that defines which axis to get the
coordinate of. Possibilities are:
JAX (0) - Joystick A, X axis
JAY (1) - Joystick A, Y axis
JBX (2) - Joystick B,